home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.List;
-
- public class MatchForm implements CommandListener, ChessDisplayable {
- private ChessLogic chesslogic = null;
- private ChessDisplayable chessreturn = null;
- private List myScreen;
- private Command OKCommand;
- private Command backCommand;
-
- public MatchForm(String var1, ChessLogic var2, ChessDisplayable var3) {
- this.chesslogic = var2;
- this.chessreturn = var3;
- this.initialize(var1);
- }
-
- public void commandAction(Command var1, Displayable var2) {
- if (var1 != this.OKCommand && var1 != List.SELECT_COMMAND) {
- if (var1 == this.backCommand) {
- this.chessreturn.makeCurrent(CU.getDisplay());
- }
-
- } else {
- this.myScreen.setTitle("Making match, wait");
- ChessGame var3 = this.chesslogic.getChessGame();
- if (var3.postActive()) {
- MessageForm var4 = new MessageForm("Making match", "Please wait", this);
- var4.makeCurrent(CU.getDisplay());
- } else {
- this.match(this.myScreen.getString(this.myScreen.getSelectedIndex()));
- }
-
- }
- }
-
- private void initialize(String var1) {
- this.myScreen = new List("Match", 3);
- this.OKCommand = new Command("OK", 4, 1);
- this.backCommand = new Command("Back", 2, 1);
- StringTokenizer var2 = new StringTokenizer(var1, " 1234567890+-\t\n\r\f");
- String var3 = "";
-
- while(var2.hasMoreElements() && !var3.equals("players")) {
- var3 = (String)var2.nextElement();
- if (!var3.equals("players") && !var3.equals(CU.getUserName())) {
- this.myScreen.append(var3, (Image)null);
- }
- }
-
- this.myScreen.addCommand(this.OKCommand);
- this.myScreen.addCommand(this.backCommand);
- }
-
- public void makeCurrent(Display var1) {
- var1.setCurrent(this.myScreen);
- this.myScreen.setCommandListener(this);
- }
-
- private boolean match(String var1) {
- ChessGame var3 = this.chesslogic.getChessGame();
- StringTokenizer var4 = new StringTokenizer(var1, " 1234567890+-:^.(\t\n\r\f");
-
- String var2;
- try {
- var2 = (String)var4.nextElement();
- } catch (Exception var5) {
- CU.shout("error in playername");
- return false;
- }
-
- var3.doPost("match " + var2 + " 30 30", true);
- return true;
- }
- }
-